import { NuxtAxiosInstance } from '@nuxtjs/axios'
import { delaySomeTime } from '@/utils'

export default ($axios: NuxtAxiosInstance) => ({
    justTest() {
        return new Promise((resolve, reject) => {
            delaySomeTime(300).then(() => {
                resolve('测试成功啦')
            })
        })
    },
    getInfo() {
        return $axios.get('user/list')
    },
    randomResult() {
        return new Promise((resolve, reject) => {
            const mm = Math.floor(Math.random() * 1000)
            delaySomeTime(mm).then(() => {
                if (mm > 500) {
                    reject('test failed...')
                } else {
                    resolve('test success emm...')
                }
            })
        })
    },
})
